Skip to content
  • 0 Votes
    5 Posts
    2k Views
    raven-worxR

    @mghqt
    i assume CWidget class is the main widget (window)?
    How do you compose/layout the form items? Are you using sub-widgets containers?

    Anyways you should do like you did for pos4 if you want to map a child to a parent.

    QPoint childPos=ui->label_2->mapTo(this, ui->label_2->pos());
  • Qt3d points and lines

    Unsolved General and Desktop
    18
    0 Votes
    18 Posts
    11k Views
    A

    Hi! I wrote resolution like @AlanWasHere, but a little clearer

    void addLine(QEntity *parentEntity, const QVector3D &srcPos, const QVector3D &targPos) { auto edgeEntity = new QEntity{parentEntity}; auto cylinder = new QCylinderMesh{edgeEntity}; auto len = srcPos.distanceToPoint(targPos); cylinder->setLength(len); cylinder->setRadius(0.1f); auto transPoint = targPos - srcPos; auto xAngle = atan(sqrt(pow(transPoint.z(), 2) + pow(transPoint.x(), 2)) / transPoint.y()) / M_PI * 180; auto yAngle = (transPoint.x() == 0 && transPoint.z() == 0) ? 0 : atan(transPoint.x() / transPoint.z()) / M_PI * 180; auto transform = new Qt3DCore::QTransform{edgeEntity}; transform->setRotationX(xAngle); transform->setRotationY(yAngle); transform->setTranslation((srcPos + targPos) / 2); auto material = new QPhongMaterial{edgeEntity}; material->setDiffuse("#ffff00"); edgeEntity->addComponent(cylinder); edgeEntity->addComponent(transform); edgeEntity->addComponent(material); }
  • 0 Votes
    3 Posts
    2k Views
    J

    or u can split one line two more as u want